<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" href="./css/api.css" />
    <link rel="stylesheet" href="./css/common.css" />
    <link rel="stylesheet" href="./css/font/iconfont.css">
</head>
<body ontouchstart="">
    <div id="wrap">
        <div id="main">

        </div>
        <div id="footer">
            <!-- 原生代替tabBar -->
            <ul id="footer_list">
                <li class="list_li home active" onclick="changeIndexFrame(0);" tapmode="tap-active">
                	<i class="icon iconfont icon-shouye1-copy"></i>
                    <span class="text">首页</span>
                </li>
                <li class="list_li list" onclick="changeIndexFrame(1);" tapmode="tap-active">
                	<i class="icon iconfont icon-icon--1"></i>
                    <span class="text">书画专区</span>
                </li>
                <li class="list_li frofile" onclick="openLogin();" tapmode="tap-active">
                	<i class="icon iconfont icon-wode"></i>
                    <span class="text">我的</span>
                </li>
                <li class="list_li help" onclick="openHelp();" tapmode="tap-active">
                	<i class="icon iconfont icon-bangzhu"></i>
                    <span class="text">帮助</span>
                </li>
            </ul>
        </div>
    </div>
</body>
<script src="./script/api.js"></script>
<script src="./script/zepto.js"></script>
<script src="./script/common.js"></script>
<script src="./script/base.js"></script>
<script>
    // 下方tabBar，不好用放弃，用原生写
    var aFooterList = $api.domAll('#footer_list .list_li');
    var navBarFun = $api.dom('#navBar_fun');
    var aNavBarBtn = $api.domAll('#navBar_fun .navBar_btn');
    var navBarBar = $api.dom('#navBar_fun .navBar_bar');

    var frameJson = {
      '0': 'home.html',
      '1': 'list.html?bType=7',
      '2': 'profile.html',
      '3': 'help.html',
    };

    // set show which frame
    var changeIndexFrame = function(index){
      $('#footer_list .list_li')
        .eq(index)
        .addClass('active')
        .siblings()
        .removeClass('active');
        /*listBar.style.webkitTransform = 'translateX('+index*100+'%)';*/
      openIndexFrames(index);
    };


    // 通用header的window
    var indexOpenCommon = function(name, title){
      api.openWin({
        name: name,
        url: './html/detailframes/'+name+'.html',
        pageParam: {
          name: name,
          title: title
        },
        rect: {
          x: 0,
          y: 0,
          w: 'auto',
          h: 'auto'
        }
      });
    }
    // 通用header的window end


    apiready = function(){

        // 阻止首页弹动
        api.setWinAttr({
            bounces: false
        });
        // 阻止首页弹动 end
        /*
        window.header = $api.byId('header');
        $api.fixStatusBar(header);
        var headerPos = $api.offset(header);*/
        var main = $api.byId('main');
        var mainPos = $api.offset(main);
        var footer = $api.byId('footer');
        var footerPos = $api.offset(footer);

        // 切换frame
        // 打开app先设置funIndex为0；
        $api.setStorage('funIndex',0);
        $api.setStorage('sh',mainPos.h);
        window.openIndexFrames = function(index){
            var funIndex = $api.getStorage('funIndex');
            var url = 'html/main/'+frameJson[index];
            if(index == 2){
                if(!isLogined()){
                    url = 'html/login.html';
                }
            }
            api.openFrame({
                name: frameJson[index],
                url: url,
                bounces: false,
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: mainPos.h
                }
            });
        };
        changeIndexFrame(0);
    };

    // 新窗口  打开帮助
    function openHelp() {
      api.openWin({
        name: 'help',
        url: './html/main/help.html',
      });
    }

    // 新窗口  打开帮助
    function openLogin() {
      api.openWin({
        name: 'login',
        url: './html/login.html',
      });
    }
</script>
</html>
